﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PatternPolicy
{
    /// <summary>
    /// 注意： 策略模式关注选择做不同事情    但状态模式关注同一件事不同状态的不同做法（实现）
    /// 策略模式和状态模式几乎结构一样
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Enviroment enviroment = new Enviroment();
            enviroment.SetPolicy(new MakeFood());
            enviroment.DoPoilcy();
            enviroment.SetPolicy(new WashCloth());
            enviroment.DoPoilcy();
            enviroment.SetPolicy(new CleanAll());
            enviroment.DoPoilcy();
        }
    }

    interface IPolicy
    {
        void doWork();
    }

    class MakeFood : IPolicy
    {
        public void doWork()
        {
            Console.WriteLine("MakeFood!!");
        }
    }

    class WashCloth : IPolicy
    {
        public void doWork()
        {
            Console.WriteLine("WashCloth!!");
        }
    }

    class CleanAll : IPolicy
    {
        public void doWork()
        {
            Console.WriteLine("CleanAll!!");
        }
    }

    class Enviroment
    {
        IPolicy policy = null;
       public void SetPolicy(IPolicy _policy)
        {
            policy = _policy;
        }

        public void DoPoilcy()
        {
            policy.doWork();
        }
    }



}
